package org.korosoft.rusalad.syncnrun.tools;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * Socket factory definition
 *
 * @author Dmitry Korotkov
 * @since 1.0
 */
public interface SocketFactory {
    /**
     * Creates listening server socket
     *
     * @param port TCP port to listen
     * @return listening server socket
     * @throws java.io.IOException when IO exception occurs
     */
    ServerSocket createServerSocket(int port) throws IOException;

    /**
     * Connects to remote socket and returns client socket.
     *
     * @param host Host to connect to
     * @param port TCP port to connect to
     * @return Connected socket
     * @throws java.io.IOException when IO exception occurs
     */
    Socket createClientSocket(String host, int port) throws IOException;
}
